package cn.pet_know.controller;

import cn.pet_know.common.result.R;
import cn.pet_know.entity.dto.KnowledgeDTO;
import cn.pet_know.entity.vo.KnowledgeVO;
import cn.pet_know.service.KnowledgeService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/knowledge")
public class KnowledgeController {

    @Resource
    private KnowledgeService knowledgeService;

    @PostMapping("/add")
    public R<Boolean> add(@RequestBody KnowledgeDTO knowledgeDTO) {
        return R.ok(knowledgeService.add(knowledgeDTO));
    }
    @PostMapping("/list")
    public R<List<KnowledgeVO>> list(@RequestBody KnowledgeDTO knowledgeDTO) {
        return R.ok(knowledgeService.listKnowledge(knowledgeDTO));
    }
    @PostMapping("/del")
    public R<Boolean> del(@RequestBody KnowledgeDTO knowledgeDTO) {
        return R.ok(knowledgeService.del(knowledgeDTO));
    }
    @PostMapping("/update")
    public R<Boolean> update(@RequestBody KnowledgeDTO knowledgeDTO) {
        return R.ok(knowledgeService.knowUpdate(knowledgeDTO));
    }
    @PostMapping("/page")
    public R<Page<KnowledgeVO>> page(@RequestBody KnowledgeDTO knowledgeDTO) {
        return R.ok(knowledgeService.queryPage(knowledgeDTO));
    }
    /**
     * 审核
     * @param knowledgeDTO
     * @return
     */
    @PostMapping("/review")
    public R<Boolean> review(@RequestBody KnowledgeDTO knowledgeDTO) {
        return R.ok(knowledgeService.review(knowledgeDTO));
    }


}